import { Login, Result } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import qs from "qs";

import http from "@/api";

/**
 * @name 登录模块
 */
// * 用户登录接口
export const loginApi = (params: Login.ReqLoginForm) => {
	return http.post<string>(`/user/login`, params);
	// return http.post<Login.ResLogin>(PORT1 + `/login`, {}, { params }); // post 请求携带 query 参数  ==>  ?username=admin&password=123456
	// return http.post<Login.ResLogin>(PORT1 + `/login`, qs.stringify(params)); // post 请求携带 表单 参数  ==>  application/x-www-form-urlencoded
	// return http.post<Login.ResLogin>(PORT1 + `/login`, params, { headers: { noLoading: true } }); // 控制当前请求不显示 loading
};

// * 获取按钮权限
export const getAuthorButtons = () => {
	// return http.get<Login.ResAuthButtons>(PORT1 + `/auth/buttons`);
	return Promise.resolve({ data: { add: true, delete: true } });
};

// * 获取菜单列表（用于校验权限，暂时返回固定）
export const getMenuList = () => {
	// return http.get<Menu.MenuOptions[]>(PORT1 + `/menu/list`);
	return Promise.resolve({
		data: [
			{
				customIcon: "mdi:home",
				// icon: "HomeOutlined",
				path: "/home/index",
				title: "首页"
			},
			{
				customIcon: "mdi:bullhorn-variant",
				path: "/noticeAdmin/index",
				title: "通知管理"
			},
			{
				customIcon: "ep:goods-filled",
				path: "/Goods",
				title: "商品管理",
				children: [
					{
						customIcon: "material-symbols:format-list-bulleted",
						path: "/Goods/list",
						title: "商品列表"
					},
					{
						customIcon: "ic:round-add-box",
						path: "/Goods/add",
						title: "商品发布"
					}
				]
			},
			{
				customIcon: "material-symbols:android-recorder",
				path: "/OrderAdmin",
				title: "订单管理",
				children: [
					{
						customIcon: "material-symbols:list-alt",
						path: "/OrderAdmin/List",
						title: "订单列表"
					},
					{
						customIcon: "material-symbols:format-list-bulleted",
						path: "/OrderAdmin/Comment",
						title: "评价列表"
					}
				]
			},
			{
				customIcon: "ic:sharp-vertical-distribute",
				path: "/GoodsSku",
				title: "规格管理",
				children: [
					{
						customIcon: "ion:ellipsis-vertical-circle",
						path: "/GoodsSku/List",
						title: "规格列表"
					},
					{
						customIcon: "ion:ellipsis-vertical-sharp",
						path: "/GoodsSku/Sku",
						title: "Sku列表"
					}
				]
			},
			{
				customIcon: "material-symbols:list-alt",
				path: "/skuCategory/List",
				title: "分类管理"
			},
			{
				customIcon: "bx:category",
				path: "/categoryAdmin/List",
				title: "类别管理"
			},
			{
				customIcon: "ph:user-rectangle",
				path: "/User/Index",
				title: "用户中心"
			}
		]
	});
};
